package com.hnevc.xiewenguang;

import java.util.Random;

/**
 * 冒泡排序
 *
 *
 */

public class Example03 {
    public static void main(String[] args) {
        int [] a = {1,9,3,7,4,2,5,0,6,8};
        //算法交换元素的执行总数
        int length = a.length;
        for (int i = 0; i < length; i++) {
            for (int j = 0; j < length - 1 - i; j++) {
                if (a[j] > a[j + 1]) {
                    int temp = a[j];
                    a[j] = a[j + 1];
                    a[j + 1] = temp;
                }
            }
        }
        for (int i : a) {
            System.out.print(i + ",");
        }
        System.out.println();
    }
}
